﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.Common;

namespace WFBot.Data.Tests
{
    public abstract class DatabaseTest : IDisposable
    {
        protected readonly DatabaseFactory databasefactory;
        protected readonly UnitOfWork unitOfWork;

        protected DatabaseTest()
        {
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["WFBotDatabase"];

            var providerName = connectionStringSettings.ProviderName;
            var connectionString = connectionStringSettings.ConnectionString;

            var providerFactory = DbProviderFactories.GetFactory(providerName);

            databasefactory = new DatabaseFactory(providerFactory, connectionString);

            unitOfWork = new UnitOfWork(databasefactory);
        }

        public virtual void Dispose()
        {
            databasefactory.Dispose();
        }
    }
}
